﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Peekaboo2008.dao;
using System.Configuration;
using CrystalDecisions.CrystalReports.Engine;

namespace Peekaboo2008.view
{
    public partial class FormBaoCaoBanHangVaThuTienTheoNgay : Form
    {
        public FormBaoCaoBanHangVaThuTienTheoNgay()
        {
            InitializeComponent();
            LoadChiNhanh();
        }


        /**/
        // Lay du lieu tu table ChiNhanh bang store sp_ChiNhanh_GopTenVaDiaChi do vao cbbChiNhanh
        /**/

        public void LoadChiNhanh()      
        {
            cbbChiNhanh.DataSource = ChiNhanhDAO.GopTenVaDiaChi();
            cbbChiNhanh.DisplayMember = "Chi_nhanh";
            cbbChiNhanh.ValueMember = "ID";
        }     

        private void btnKetThuc_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnChapNhan_Click(object sender, EventArgs e)
        {
            timer.Interval = 250;
            timer.Start();           
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            this.progressBar.Value += 10;
            if (this.progressBar.Value == this.progressBar.Maximum)
            {                
                timer.Stop();
                String chiNhanh = Convert.ToString(cbbChiNhanh.SelectedValue.ToString());
                String ngayXem = dateTimePicker1.Value.Month.ToString() + "/" + dateTimePicker1.Value.Day.ToString() + "/" + dateTimePicker1.Value.Year.ToString();
                FormReportViewerBanHangVaThuTienTheoNgay frmBaoCao = new FormReportViewerBanHangVaThuTienTheoNgay(chiNhanh, ngayXem);
                if (frmBaoCao.IsDisposed)
                {
                    MessageBox.Show("Chi nhánh này không có dữ liệu để báo cáo. \nHãy chọn chi nhánh khác.");
                }
                else
                {
                    frmBaoCao.ShowDialog();
                }
                this.progressBar.Value = 0;
            }
        }
    }
}
